import request from '../utils/request'
let token = localStorage.token
let service = {
    getAllRoles(param){
        return request({
            method:'GET',
            url:`/role`,
            headers:{
                Authentication:token,
                'Content-Type':'application/x-www-form-urlencoded'
            },
            params:{
                pageSize:param.pageSize,
                roleName:param.roleName,
                createTimeFrom:param.createTimeFrom,
                createTimeTo:param.createTimeTo
            }
        })
    },
    delRole(roleId){
        return request({
            method:'delete',
            url:`/role/${roleId}`,
            headers:{
                Authentication:token,
                'Content-Type':'application/x-www-form-urlencoded'
            },
        })
    },
    updateRole(param){
        console.log(param);
        return request({
            method:'PUT',
            url:'/role',
            data:param,
            headers:{
                Authentication:token,
                'Content-Type':'application/x-www-form-urlencoded'
            },
        })
    },
    addRole(param){
        return request({
            method:'POST',
            url:'/role',
            data:param,
            headers:{
                Authentication:token,
                'Content-Type':'application/x-www-form-urlencoded'
            },
        })
    },
    roleFromMenu(roleID){
        return request({
            method:'GET',
            url:`/role/menu/${roleID}`,
            headers:{
                Authentication:token,
                'Content-Type':'application/x-www-form-urlencoded'
            },
        })
    }
}

export default service